<!-- 系统自动生成 Date:2021-02-21 22:43 -->
<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="系统消息" bodyClass="gray-bg animated fadeInRight" isAnimation=false libs=["table","zTree","layout-latest"]/>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <@f.form id="msg-form" class="form-inline">
                <div class="select-list">
                    <ul>
                        <li>
                            <label> ${i18n("消息标题")}：</label>
                            <@f.input name="msgTitle"/>
                        </li>
                        <li>
                            <label> ${i18n("消息等级")}： </label>
                            <@f.select name="msgLevel" dictType="sys_notice_level" blankValue="" blankLabel="所有"/>
                        </li>
                        <li>
                            <label> ${i18n("是否开放评论")}： </label>
                            <@f.select name="isComments" dictType="sys_normal_disable" blankValue="" blankLabel="所有"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;&nbsp;${i18n("查询")}</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;${i18n("重置")}</a>
                        </li>
                    </ul>
                </div>
            </@f.form>
        </div>
        <@table id="bootstrap-table">
            <@shiro.hasPermission name="sys:msg:edit">
                <a class="btn btn-primary single disabled" onclick="opt.operate.editTab()"><i class="fa fa-pencil-square-o"></i>&nbsp;${i18n("修改")}</a>
            </@shiro.hasPermission>
            <@shiro.hasPermission name="sys:msg:del">
                <a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()"><i class="fa fa-remove"></i> ${i18n("删除")}</a>
            </@shiro.hasPermission>
        </@table>
    </div>
</div>
<@footer>
<script type="text/javascript">
    var editFlag = "${permission.hasPermi("sys:msg:edit")}";
    var listFlag = "${permission.hasPermi("sys:msg:add")}";
    var delFlag = "${permission.hasPermi("sys:msg:del")}";
    var visible = ${permission.isPermitteds("sys:msg:edit,sys:msg:del,sys:msg:add")?string('true', 'false')};
    var msgLevelDatas = ${dict.getDictListJson('sys_notice_level')};
    var isCommentsDatas = ${dict.getDictListJson('sys_msg_comments')};
    var prefix = baseURL + "sys/msg";

    $(function() {
        var options = {
            url: prefix + "/list",
            addUrl: prefix + "/add",
            editUrl: prefix + "/edit/{id}",
            viewUrl: prefix + "/view/{id}",
            delUrl: prefix + "/del",
            modalName: "${i18n("系统消息")}",
            clickToSelect: false,
            uniqueId:  'id',/* 唯一ID */
            escape: true,/* 分页设置 */
            showPageGo: true,/* 分页设置 */
            pageSize: 10,/* 分页设置 */
            pageList: [10, 30, 50],/* 分页设置 */
            columns:[
                {title: $.i18n.prop("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }}
                ,{field : 'id',title : '${i18n("编号")}',visible: false}
                ,{field : 'msgTitle',title : '${i18n("消息标题")}'}
                ,{field : 'msgLevel',title : '${i18n("消息等级")}',formatter: function(value, row, index) {
                    return opt.common.selectDictLabels(msgLevelDatas, value);
                }}
                ,{field : 'isComments',title : '${i18n("是否开放评论")}',formatter: function(value, row, index) {
                    return opt.common.selectDictLabels(isCommentsDatas, value);
                }}
                ,{field : 'pushDate',title : '${i18n("发送时间")}'}
                ,{title:"${i18n("操作")}",align: 'center',visible:visible,formatter: function(value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-default btn-xs preview " href="javascript:void(0)" onclick="openView(\''+row.id+'\',\''+opt.common.escape(row.msgTitle.replaceAll("'",""))+'\')"><i class="fa fa-eye"></i> ${i18n("查看")}</a> ');
                    <#--actions.push('<a class="btn btn-default btn-xs preview " href="javascript:void(0)" onclick="opt.operate.editTab(\''+row.id+'\',\''+row.msgTitle+'\')"><i class="fa fa-eye"></i> ${i18n("查看")}</a> ');-->
                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="opt.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>${i18n("修改")}</a> ');
                    actions.push('<a class="btn btn-danger btn-xs ' + delFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.id + '\')"><i class="fa fa-remove"></i> ${i18n("删除")}</a>');
                    return actions.join('');
                }}
            ]
        };
        $.table.init(options);
    });

    function openView(id,editFlag){
        // opt.operate.view(id,editFlag,opt.operate.edit);
        // opt.operate.editTab(id,editFlag);
        opt.modal.openTab(editFlag,prefix + "/view/"+id);
    }
</script>
</@footer>
</@pageTheme>